package btree4j.template;

import java.io.Serializable;

public class Column implements Serializable {
    private static final long serialVersionUID = 1L;

    private String name;
    private String dataType;
    private boolean primaryKey;
    private boolean nullable;
    private boolean indexed; // 新增二级索引标记

    public Column(String name, String dataType) {
        this.name = name;
        this.dataType = dataType;
        this.nullable = true;
    }

    public Column(String name, String dataType, boolean primaryKey) {
        this(name, dataType);
        this.primaryKey = primaryKey;
    }

    public Column(String name, String dataType, boolean primaryKey, boolean nullable) {
        this(name, dataType, primaryKey);
        this.nullable = nullable;
    }

    public Column(String name, String dataType, boolean primaryKey, boolean nullable, boolean indexed) {
        this(name, dataType, primaryKey);
        this.nullable = nullable;
        this.indexed = indexed;
    }

    // 新增getter/setter
    public boolean isIndexed() {
        return indexed;
    }

    public void setIndexed(boolean indexed) {
        this.indexed = indexed;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public boolean isPrimaryKey() {
        return primaryKey;
    }

    public void setPrimaryKey(boolean primaryKey) {
        this.primaryKey = primaryKey;
    }

    public boolean isNullable() {
        return nullable;
    }

    public void setNullable(boolean nullable) {
        this.nullable = nullable;
    }

    @Override
    public String toString() {
        return "Column [name=" + name + ", dataType=" + dataType + ", primaryKey=" + primaryKey
                + ", nullable=" + nullable + ", indexed=" + indexed + "]";
    }
}